<%@ include file="../common.jsp" %>

<script type="text/javascript">

var lastsel;

jQuery(document).ready(function(){
	jQuery('#filterList').jqGrid({
		url: contextRoot + 'generateWFRoleAssignTable.htm',
		datatype: 'json',
		mtype: 'GET',
		loadonce:true,
		colNames:['DOCUMENT TYPE','DOCUMENT LOCATION','DOCUMENT DEPARTMENT','DOCUMENT REVIEWER','DOCUMENT APPROVER','MASTER CODE'],
		colModel:[
				  {name:'documentType' ,index:'documentType',width:150 ,editable:true ,edittype:'select' ,editoptions:{dataUrl:contextRoot + 'loadSelectDataForType.htm'}},
		          {name:'documentLocation' ,index:'documentLocation', width:150 ,editable:true ,edittype:'select' ,editoptions:{dataUrl:contextRoot + 'loadSelectDataForLocation.htm', dataEvents:[{type:'change',data:{},fn:function(){loadDepttForBU(this.id,'documentDepartment');}}]}},
		          {name:'documentDepartment' ,index:'documentDepartment', width:150 ,editable:true ,edittype:'select' ,editoptions:{dataUrl:contextRoot + 'loadSelectDataForDepartment.htm'}},
		          {name:'reviewer' ,index:'reviewer', width:150, editable:true, edittype:'text', editoptions:{size:15,dataEvents:[{type:'click',data:{role:'reviewer'},fn:function(){showUserLookUpDialogForWF('ROLE_REVIEWER');}}]}},
		          {name:'approver' ,index:'approver', width:150, editable:true, edittype:'text', editoptions:{size:15,dataEvents:[{type:'click',data:{role:'approver'},fn:function(){showUserLookUpDialogForWF('ROLE_APPROVER');}}]}},
		          {name:'masterCode', index:'masterCode',width:100,hidden:true,hidedlg:true,editable:true}
		         ],    
		jsonReader : {
		             root: "rows",
		             page: "page",
		             total: "total",
		             records: "records" 
		       },
		ondblClickRow: function(documentType){
			if(documentType){
				jQuery('#filterList').jqGrid('editGridRow',documentType, {readOnly:true, checkOnUpdate:true, checkOnSubmit : true, reloadAfterSubmit:false, closeOnEscape:true, closeAfterSubmit:true});
			}
		},
		rowNum: 180,
		rowList: [30,60,90,120,150,180],
		rownumbers:true,
		caption: 'Assign Approver and Reviewer',
		pager: '#pager',
		height: 'auto',
		editurl: contextRoot + 'editDataInWFTable.htm'		
		
	});
	jQuery("#filterList").jqGrid('navGrid','#pager',{edit:true, add:false, del:false},{checkOnUpdate:true, checkOnSubmit : true, reloadAfterSubmit:false, closeOnEscape:true, closeAfterSubmit:true});
	jQuery('#filterList').jqGrid.trigger('reloadGrid');
	
});
	
</script>
	<table id="filterList"></table>
	<div id="pager"></div>